package com.tencent.wxcloudrun.pojo.bo;

import com.alibaba.fastjson2.JSON;
import lombok.Data;

import java.util.ArrayList;
import java.util.List;

/**
 * 多媒体核心字段
 */
@Data
public class MediaInfo {

    private String type;

    private String fileID;

    public static MediaInfo transMedia(MediaOriInfo mediaOriInfo) {
        MediaInfo mediaInfo = new MediaInfo();
        mediaInfo.setType(mediaInfo.getType());
        mediaInfo.setFileID(mediaOriInfo.getFileID());
        return mediaInfo;
    }

    public static List<MediaInfo> transMediaList(List<MediaOriInfo> mediaOriInfoList) {
        List<MediaInfo> mediaInfoList = new ArrayList<>();
        for (MediaOriInfo mediaOriInfo : mediaOriInfoList) {
            MediaInfo mediaInfo = transMedia(mediaOriInfo);
            mediaInfoList.add(mediaInfo);
        }
        return mediaInfoList;
    }

    public static String transMediaListToStr(List<MediaOriInfo> mediaOriInfoList) {
        return JSON.toJSONString(transMediaList(mediaOriInfoList));
    }

    public static String transMediaListToStr(MediaOriInfo mediaOriInfoList) {
        return JSON.toJSONString(transMedia(mediaOriInfoList));
    }
}
